<?php
	echo "<h1>What's new</h1>";
	error_reporting (E_ALL ^ E_NOTICE);
	$blogdate = $_POST["blogdate"];
	$blogtitle = $_POST["blogtitle"];
	$blogcontent = $_POST["blogcontent"];
	$blogauthor = $_POST["blogauthor"];
	if ($blogdate != "" && $blogtitle != "" && $blogcontent != "" && $blogauthor != "") {
		$xml = simplexml_load_file('./data/blog.xml');
		$blog = $xml->addChild('blog');
		$date = date_create($blogdate);
		$date = $blog->addChild('date', date_format($date, 'Y-m-d H:i:s'));
		$author = $blog->addChild('author', $blogauthor);
		$content = $blog->addChild('content', htmlspecialchars(utf8_encode($blogcontent)));
		$author = $blog->addChild('author', $blogauthor);
		$xml->asXML('./data/blog.xml');
	}
	$xml = simplexml_load_file('./data/blog.xml');
	foreach ($xml->children() as $child) {
		echo "<p>" . $child->content . "</p><br/>";
		$date = date_create($child->date);
		echo "posted by " . $child->author . " on " . date_format($date, 'Y-m-d H:i:s') . "<br/>";
		echo "<hr/>";
	}
?>